package register
{{$Namespace := .Namespace}}
import (
    {{range $aggName, $agg := .Aggregates}}
    {{$agg.FileName}}_handler "{{$Namespace}}/pkg/query-service/application/internals/{{$agg.FileName}}/handler"
    {{- end }}
	"github.com/liuxd6825/dapr-go-ddd-sdk/restapp"
)


// 所有注册的消息订阅
var _subscribes = make([]restapp.RegisterSubscribe, 0)

//
// GetRegisterSubscribe
// @Description: 获取所有注册的消息订阅
// @return []restapp.RegisterSubscribe
//
func GetRegisterSubscribe() []restapp.RegisterSubscribe {
	return _subscribes
}

//
// AddSubscribe
// @Description: 添加消息订阅
// @param subs
//
func AddSubscribe(subs ...restapp.RegisterSubscribe) {
	for _, sub := range subs {
		_subscribes = append(_subscribes, sub)
	}
}

//
//  initSubscribe
//  @Description: 初始化消息订阅
//
func initSubscribe() {
	{{- range $aggName, $agg := .Aggregates}}
	AddSubscribe({{$agg.FileName}}_handler.New{{$agg.Name}}Subscribe())
	{{- range $entityName, $entity := $agg.Entities}}
    AddSubscribe({{$agg.FileName}}_handler.New{{$entity.Name}}Subscribe())
	{{- end }}
	{{- end }}
}


